<?php 

include 'operations/connection.php';		
	$query = mysql_query("SELECT dl.IDDepartment,dl.DepartmentName FROM department_lang dl WHERE dl.LangID='$lang' ORDER BY dl.IDDepartment; ");
	$querygroup = mysql_query("SELECT id,name FROM groupapprove WHERE employee_id='$id_employee';");
	$_SESSION['check']=1;

$listapprove=array();		
$_SESSION['listapprove']=$listapprove;	

?>
<script type="text/javascript">
  
	
    function handler(str) {
    	if (str==""){
    		document.getElementById("approve").innerHTML="";
    		return;
    	} 
    	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
    		xmlhttp=new XMLHttpRequest();
    	}else{// code for IE6, IE5
    		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    	}
    	xmlhttp.onreadystatechange=function(){
    										  if (xmlhttp.readyState==4 && xmlhttp.status==200){
    										    	document.getElementById("approve").innerHTML=xmlhttp.responseText;
    										  }
    									  }
    	xmlhttp.open("GET","ajax/getApprove.php?check="+str,true);
    	xmlhttp.send();
    }
    function delApprove(str1)
    {
    	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
    		xmlhttp=new XMLHttpRequest();
    	}else{// code for IE6, IE5
    		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    	}
    	xmlhttp.onreadystatechange=function(){
    										  if (xmlhttp.readyState==4 && xmlhttp.status==200){
    										    	document.getElementById("approve").innerHTML=xmlhttp.responseText;
    										  }
    									  }
    	xmlhttp.open("GET","ajax/delApprove11.php?q="+str1,true);
    	xmlhttp.send();
    }

    function delGroupApp()
    {
    	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
    		xmlhttp=new XMLHttpRequest();
    	}else{// code for IE6, IE5
    		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    	}
    	xmlhttp.onreadystatechange=function(){
    										  if (xmlhttp.readyState==4 && xmlhttp.status==200){
    										    	document.getElementById("groupapp").innerHTML=xmlhttp.responseText;
    										  }
    									  }
    	xmlhttp.open("GET","ajax/delGroupApp.php",true);
    	xmlhttp.send();
    }

    function delReference(str1)
    {

    	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
    		xmlhttp=new XMLHttpRequest();
    	}else{// code for IE6, IE5
    		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    	}
    	xmlhttp.onreadystatechange=function(){
    										  if (xmlhttp.readyState==4 && xmlhttp.status==200){
    										    	document.getElementById("approve").innerHTML=xmlhttp.responseText;
    										  }
    									  }
    	xmlhttp.open("GET","ajax/delReference.php?q="+str1,true);
    	xmlhttp.send();
    }
    function addReference(str)
    {
    	if (str==""){
    		document.getElementById("approve").innerHTML="";
    		return;
    	} 
    	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
    		xmlhttp=new XMLHttpRequest();
    	}else{// code for IE6, IE5
    		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    	}
    	xmlhttp.onreadystatechange=function(){
										    		var body = document.getElementById('approve');
													body.setAttribute('style','opacity:.5; position:relative;cursor: wait;  ');
													
													var d=document.createElement('div');
													d.setAttribute('style','display: block;visibility: visible; position: absolute;  z-index: 999; top: 0px; left: 0px; width: 105%; height: 105%; text-align: center;  filter: alpha(opacity=5); opacity: 0.5; ');
													
													var image=document.createElement('img');
													image.setAttribute('src','images/loading1.gif');
													image.setAttribute('style','position:absolute; left:0px; top:0px; right:0; bottom:0; margin:auto');
													
													d.appendChild(image);
													
												    body.appendChild(d);	
												    
												  if (xmlhttp.readyState==4 && xmlhttp.status==200){
												    	document.getElementById("approve").innerHTML=xmlhttp.responseText;
												    	document.getElementById('approve').setAttribute('style','opacity:1; position:relative;');
												  }
    									  }
    	xmlhttp.open("GET","ajax/addReference.php?q="+str,true);
    	xmlhttp.send();
    }
    function showAllApprove(str)
    {
    	if (str==""){
    		document.getElementById("approve").innerHTML="";
    		return;
    	} 
    	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
    		xmlhttp=new XMLHttpRequest();
    	}else{// code for IE6, IE5
    		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    	}
    	xmlhttp.onreadystatechange=function(){
									    		var body = document.getElementById('approve');
												body.setAttribute('style','opacity:.5; position:relative;cursor: wait;  ');
												
												var d=document.createElement('div');
												d.setAttribute('style','display: block;visibility: visible; position: absolute;  z-index: 999; top: 0px; left: 0px; width: 105%; height: 105%; text-align: center;  filter: alpha(opacity=5); opacity: 0.5; ');
												
												var image=document.createElement('img');
												image.setAttribute('src','images/loading1.gif');
												image.setAttribute('style','position:absolute; left:0px; top:0px; right:0; bottom:0; margin:auto');
												
												d.appendChild(image);
												
											    body.appendChild(d);	
											    
											  if (xmlhttp.readyState==4 && xmlhttp.status==200){
											    	document.getElementById("approve").innerHTML=xmlhttp.responseText;
											    	document.getElementById('approve').setAttribute('style','opacity:1; position:relative;');
											  }
    									  }
    	xmlhttp.open("GET","ajax/showAllApprove.php?q="+str,true);
    	xmlhttp.send();
    }

    function showApprove(str)
    {
    	if (str==""){
    		document.getElementById("approve").innerHTML="";
    		return;
    	} 
    	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
    		xmlhttp=new XMLHttpRequest();
    	}else{// code for IE6, IE5
    		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    	}
    	xmlhttp.onreadystatechange=function(){
										    		var body = document.getElementById('approve');
													body.setAttribute('style','opacity:.5; position:relative;cursor: wait;  ');
													
													var d=document.createElement('div');
													d.setAttribute('style','display: block;visibility: visible; position: absolute;  z-index: 999; top: 0px; left: 0px; width: 105%; height: 105%; text-align: center;  filter: alpha(opacity=5); opacity: 0.5; ');
													
													var image=document.createElement('img');
													image.setAttribute('src','images/loading1.gif');
													image.setAttribute('style','position:absolute; left:0px; top:0px; right:0; bottom:0; margin:auto');
													
													d.appendChild(image);
													
												    body.appendChild(d);	
												    
												  if (xmlhttp.readyState==4 && xmlhttp.status==200){
												    	document.getElementById("approve").innerHTML=xmlhttp.responseText;
												    	document.getElementById('approve').setAttribute('style','opacity:1; position:relative;');
												  }
    									  }
    	xmlhttp.open("GET","ajax/getApprove11.php?q="+str,true);
    	xmlhttp.send();
    }



    function showEmployee(str)
    {
    	if (str==""){
    		document.getElementById("employee").innerHTML="";
    		return;
    	} 
    	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
    		xmlhttp=new XMLHttpRequest();
    	}else{// code for IE6, IE5
    		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    	}
    	xmlhttp.onreadystatechange=function(){
										    		var body = document.getElementById('employee');
													body.setAttribute('style','opacity:.5; position:relative;cursor: wait;  ');
													
													var d=document.createElement('div');
													d.setAttribute('style','display: block;visibility: visible; position: absolute;  z-index: 999; top: 0px; left: 0px; width: 105%; height: 105%; text-align: center;  filter: alpha(opacity=5); opacity: 0.5; ');
													
													var image=document.createElement('img');
													image.setAttribute('src','images/loading1.gif');
													image.setAttribute('style','position:absolute; left:0px; top:0px; right:0; bottom:0; margin:auto');
													
													d.appendChild(image);
													
												    body.appendChild(d);	
												    
												  if (xmlhttp.readyState==4 && xmlhttp.status==200){
												    	document.getElementById("employee").innerHTML=xmlhttp.responseText;
												    	document.getElementById('employee').setAttribute('style','opacity:1; position:relative;');
												  }
    									  }
    	xmlhttp.open("GET","ajax/getEmployee11.php?q="+str,true);
    	xmlhttp.send();
    }
	
  </script>

<link	href="css/style.css" rel="stylesheet" type="text/css" />
<form method="get" action="approve.php">


<input type="hidden" name="idapprovedoc" value="<?=$idapprovedoc?>" />
<input type="hidden" name="type" value="<?=$type?>" />

<div class="main_content" style="min-height: 895px">
            <div class="top_but">
				<span class="top_but2"><?=$l_add_approve?></span>
                <input type="submit" name="action" value="<?=$l_accept?>" style="height:30px" class="btnupbg btnupload" />
			</div>
            <div style="padding:5px; border-bottom:1px dotted #aaa">
            	<table width="100%">
                	<tr>
                    	<td width="20%" style="vertical-align:top">
                        	<ul class="list_ph">
                        		<?php while ($row= mysql_fetch_array($query)){?>
                            	<li><a  onclick="showEmployee(<?=$row[IDDepartment]?>)"><?=$row[DepartmentName]?></a></li>
                                <?php }?>
                            </ul>
                        </td>
                        <td width="40%" style="vertical-align:top">
                        	<div id='employee'>
	                        	<table width="100%" class="templ" cellspacing="0">
	                            	<tr class="titapp titapp2">
	                                	<td><div align="center"><?=$l_employee_list?></div></td>
	                                    <td width="50px">
	                                   	</td>
	                                </tr>
	                                <tr>
	                                	<td colspan='2'><?=$l_no_record?></td>
	                                    
	                                </tr>
	                                
	                            </table>
                            </div>
                        </td>
                      <td width="40%" style="vertical-align: top">
                      	<div id='approve'>
                      		<table width="100%" class="templ" cellspacing="0">
	                            	<tr class="titapp titapp2">
	                                	<td><div align="center"><?=$l_approver?></div></td>
	                                    <td width="50px">
	                                   	</td>
	                                </tr>
	                                <tr>
	                                	<td colspan='2'><?=$l_no_record?></td>
	                                    
	                                </tr>
	                                
	                            </table>
	                       	  
                          </div>
                       
                      </td>                        
                    </tr>
                </table>
            </div>
            <div style="margin:10px 0"><input type="submit" value="<?=$l_accept?>" name="action" style="height:30px" class="btnupbg btnupload" /></div>
 </div>
 </form>